import queue


class SignalBuffer:
    def __init__(self):
        self.buffer = queue.Queue()

    def put(self, data):
        self.buffer.put(data)

    def get(self):
        try:
            return self.buffer.get_nowait()
        except queue.Empty:
            return None

    def is_empty(self):
        return self.buffer.empty()

    def decode(self, data, mode):
        if mode == 'HEX':
            return data.hex()
        elif mode == 'ASCII':
            return data.decode('ascii', errors='ignore')
